package cn.yunhe.dao;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.yunhe.entity.University;
import cn.yunhe.util.DButil;

public class UniverstityDaoImpl implements IUniversityDao {

	
	Connection conn = null;
	PreparedStatement ps = null;
	ResultSet rs = null;
	
	@Override
	public List<University> searchIsnefOrIstoo() {
		conn=DButil.getCon();
		List<University> list =new ArrayList<University>();
		try {
			String sql="select Universityid,uname,isnef,istoo,contacts,url from Universitys where isnef=1 or intoo=1";
			ps=conn.prepareStatement(sql);
			rs=ps.executeQuery();
			
			while(rs.next()){
				University university = new University();
				university.setUniversityid(rs.getInt("universityid"));
				university.setUname(rs.getString("uname"));
				university.setIsnef(rs.getInt("isnef"));
				university.setIstoo(rs.getInt("istoo"));
				university.setContacts(rs.getString("contacts"));
				university.setUrl(rs.getString("url"));
				list.add(university);
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		return list;
		
	}

	
	
}
